<template>
	<!-- 申请详情 -->
	<view class="box-main">

		<view class="box-top-bg">

			<!-- 导航栏 -->
			<view class="head-wrapper" id="home" :style="{ top: homeTop + 'rpx' }">
				<view class="head-menu">
					<view class='iconfont icon-fanhui2' @click="returns"></view>
					<view class="iconfont icon-shouye" @click="showNav"></view>
				</view>
			</view>
			<!-- end -->

			<view :style="{height: (homeTop+80) + 'rpx'}">
			</view>

			<view class="p-20 ml-20">
				<view style="color: #9A6748;">
					<text class="fw" style="font-size: 60rpx;">交换申请</text>
				</view>
				<view class="mt-10 " style="color: #9D6A4A">
					<text class="fs-26">有企业家向您申请交换名片</text>
				</view>
				<view style="color: #9D6A4A">
					<text class="fs-26">点击同意后双方即交换名片成功</text>
				</view>
			</view>

		</view>


		<view class="box-item-p shadow-2 p-20">
			<view style="color: #353535; " class="fs-36 fw ml-10">
				<text>申请人</text>
			</view>
			<view>
				<view @click="toPage" class="mt-30 flex ac sb ">
					<view class="flex">
						<view>
							<image :src="cardProcessing.card_info.avatar" mode="aspectFill"
								style="width: 90rpx;height: 90rpx;border-radius: 100%;"></image>
						</view>
						<view>
							<view class="ml-20">
								<text class="fw fs-32">{{cardProcessing.card_info.name || ''}}</text>
								<text class="ml-20 fs-24"
									style="color: #BCBCBC;">{{cardProcessing.card_info.position.position}}</text>
							</view>
							<view class="fs-24 ml-20 mt-10">
								<text style="color: #BCBCBC;">{{cardProcessing.card_info.position.company_name}}</text>
							</view>
						</view>
					</view>
					<view>
						<text class="iconfont icon-gengduo3 fs-26"></text>
					</view>
				</view>
			</view>
		</view>

		<view class="box-item-p shadow-2 p-20 mt-30" style="height: auto;">
			<view style="color: #353535; " class="fs-36 fw ml-10">
				<text>申请留言</text>
			</view>
			<view v-if="cardProcessing.remark" class="mt-20 ml-10">
				<text>{{cardProcessing.remark || ''}}</text>
			</view>

			<emptyPage v-else top='0' title="暂无留言">
			</emptyPage>

		</view>

		<view @click="submitClick" class="box-footer shadow-2">
			<view class="box-f-btn mt-5">
				同意
			</view>
		</view>


	</view>
</template>

<script>
	import emptyPage from '@/pages/extend/components/emptyPage.vue'
	import {
		cardDetail,
		cardAgree
	} from '@/api/extend.js'
	export default {
		components: {
			emptyPage
		},
		data() {
			return {
				leaveMsg: '',
				otherItem: {}, // 人家的名片信息
				item: {}, // 我自己的名片信息
				options: {},
				form: {
					textareaVal: ''
				},
				homeTop: 88,
			}
		},
		onLoad(options) {
			this.options = options;
			let cardInfo = uni.getStorageSync('myCardInfo');
			if (cardInfo && cardInfo.is_card) {
				this.item = cardInfo.item;
			}
		},
		computed: {
			cardProcessing() {
				return this.$store.state.extend.cardProcessing
			}
		},
		onReady() {
			this.$nextTick(function() {
				// #ifdef MP
				const menuButton = uni.getMenuButtonBoundingClientRect();
				const query = uni.createSelectorQuery().in(this);
				query
					.select('#home')
					.boundingClientRect(data => {
						this.homeTop = menuButton.top * 2 + menuButton.height - data.height;
					})
					.exec();
				// #endif
			});
		},
		methods: {
			toPage() {
				uni.navigateTo({
					url: '/pages/extend/connection/index_desc?id=' + this.cardProcessing.card_info.id
				})
			},
			closeClick() {
				this.$refs.popuplnterest.close();
			},
			submitClick() {
				uni.showLoading({
					title:'加载中...',
					mask:true
				})
				cardAgree({
					id: this.cardProcessing.id
				}).then(res => {
					uni.hideLoading();
					uni.showToast({
						title: res.message,
						icon: 'none',
						mask: true
					})
					if (res.status == 200) {
						uni.$emit('applyDescSuccessRefer');
						setTimeout(() => {
							uni.navigateBack()
						}, 1500)
					}
				})
			},
			// 后退
			returns() {
				uni.navigateBack({
					fail() {
						uni.reLaunch({
							url: '/pages/index/index'
						});
					}
				})
			},
			// 首页
			showNav() {
				uni.reLaunch({
					url: '/pages/index/index'
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.box-btn-phone:active {
		opacity: .6;
	}

	.box-btn-phone {
		font-weight: bold;
		margin-top: 5vh;
		border-radius: 10rpx;
		margin-left: auto;
		margin-right: auto;
		width: 70%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: white;
		background-color: #CF9B62;
	}

	.popuplnterest {
		padding: 20rpx;
		width: 90vw;
		height: 55vh;
		background-color: #FFFFFF;
		border-radius: 20rpx;
	}

	.box-f-btn:active {
		opacity: .5;
	}

	.box-f-btn {
		font-size: 32rpx;
		border-radius: 8rpx;
		font-weight: bold;
		text-align: center;
		line-height: 90rpx;
		height: 90rpx;
		width: 100%;
		background-color: #CF9B62;
	}

	.box-footer {
		z-index: 999;
		padding: 10rpx;
		padding-left: 20rpx;
		padding-right: 20rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		color: white;
		background-color: white;
		width: 100%;
		// height: 120rpx;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx); ///兼容 IOS<11.2/
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx); ///兼容 IOS>11.2/
		height: calc(120rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
		height: calc(120rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
	}

	.box-item-p {
		margin-left: auto;
		margin-right: auto;
		top: -120rpx;
		position: relative;
		width: calc(100% - 60rpx);
		height: 220rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
	}

	.head-wrapper {
		z-index: 999;
		display: flex;
		align-items: center;
		position: fixed;
		left: 30rpx;
		top: 0;
	}

	.head-menu {
		display: flex;
		align-items: center;
		height: 58rpx;
		width: 158rpx;
		background: rgba(255, 255, 255, 0.302);
		border: 2rpx solid rgba(0, 0, 0, 0.0588);
		border-radius: 29rpx;

		.iconfont {
			flex: 1;
			text-align: center;
			color: #000000;
			box-sizing: border-box;

			&.icon-fanhui2 {
				border-right: 1px solid rgba(0, 0, 0, 0.2);
				;
			}
		}
	}

	.box-top-bg {
		width: 100%;
		height: 500rpx;
		background-image: url('https://yjgs.jsonbug.com/test/sendqbg.png');
		background-size: 100% 100%;

	}

	.box-main {
		background-color: #F4F5FA;
	}
</style>